import { useState, useEffect } from 'react'
import axios from 'axios'
import { Table } from 'antd'
import '../mock'
const columns = [
    {
        title: 'Full Name',
        width: 100,
        dataIndex: 'name',
        key: 'name',
        fixed: 'left',
    },
    {
        title: 'Column 1',
        dataIndex: 'address',
        key: '1',
    },
    {
        title: 'Action',
        key: 'operation',
        fixed: 'right',
        width: 100,
        render: () => <a>action</a>,
    },
];

function addData(api, pagination) {
    return (Com) => {
        return () => {
            const [list, setList] = useState([])
            useEffect(() => {
                axios.get(api).then(res => {
                    console.log(res)
                    setList(res.data.list)
                })
            }, [])
            return <div>
                <Com/>
                <Table
                    columns={columns}
                    dataSource={list}
                    pagination={pagination}
                />
            </div>
        }
    }
}

export {
    addData
}